let app = getApp()
Component({
    properties: {
      label:String,
      checkvalue:{
          type:String,
          observer: function(newVal, oldVal) {
            this.update()
          }
        },
      },
      data:{
        checked:1
      },
    lifetimes: {
        attached: function () {
       }
      },
    methods: {
      changecheck:function(){
        var that=this
        if(this.data.checked==1)
        {
          this.setData({
            value:false,
            checked:-1
          })
        }
        else
        {
          this.setData({
            value:true,
            checked:1
          })
        }
        this.triggerEvent ('checked',this.data.checked)
      },
      update:function(){
        var that=this
        if(that.data.checkvalue==1)
        {
          this.setData({
            value:true,
            checked:1
          })
        }
        else
        {
          this.setData({
            value:false,
            checked:-1
          })
        }
      }
    }
});
